package com.unitech.drinks.vo;

import com.github.pagehelper.PageInfo;
import com.unitech.drinks.model.Category;
import com.unitech.drinks.model.Drink;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ResponseDrink {
    private Long id;
    private LocalDateTime createTime;
    private String name;
    private BigDecimal price;
    private String category;

    public static ResponseDrink converter(Drink drink, Map<Long, Category> categoryMap) {

        return ResponseDrink.builder()
                .id(drink.getId())
                .createTime(drink.getCreateTime())
                .name(drink.getName())
                .price(drink.getPrice())
                .category(categoryMap.get(drink.getCategoryID()).getName())
                .build();
    }
}
